package com.vr.core.system.tableInfo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vr.core.system.tableInfo.service.SlCoreTableService;
import com.vr.core.system.tableInfo.tableInfo.SlCoreTable;
import com.vr.mybatis.entity.DbConnInfoEntity;
import com.vr.tool.api.R;
import com.vr.tool.util.BaseQuery;
import com.vr.tool.util.SelectConditionUtil;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author kenson
 * @Date 2024/12/6 15:19
 */
@RequestMapping("/table")
@RestController
@AllArgsConstructor
public class TableInfoController {

    private final SlCoreTableService service;


    @PostMapping("pageList")
    public R<IPage<SlCoreTable>> listPage(@RequestBody BaseQuery<SlCoreTable> query){
        IPage page = service.page(query.getPage(), SelectConditionUtil.parseWhereSql(query.getConditions()));
        return R.ok(page);
    }

    @PostMapping("save")
    public R<Boolean> save(@RequestBody SlCoreTable slCoreTable){
        boolean save = service.save(slCoreTable);
        return R.ok(save);
    }

    @PostMapping("update")
    public R<Boolean> update(@RequestBody SlCoreTable slCoreTable){
        boolean save = service.updateById(slCoreTable);
        return R.ok(save);
    }

    @PostMapping("delete/{id}")
    public R<Boolean> update(@PathVariable("id") String id){
        boolean save = service.removeById(id);
        return R.ok(save);
    }

}




